package com.base.caselib.widget;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.base.caselib.R;
import com.base.commonlib.utils.ToastUtil;

/**
 * Created by weikailiang on 2019/10/12.
 */

public class TitleCustom extends FrameLayout{
    private TextView mTvName;
    private Context mContext;
    private ImageView mImg;
    public TitleCustom(@NonNull Context context) {
        super(context);
        this.mContext = context;
        init(null);
    }

    public TitleCustom(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        this.mContext = context;
        init(attrs);
    }

    public TitleCustom(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.mContext = context;
        init(attrs);
    }
    private void init(AttributeSet attrs){
        LayoutInflater.from(getContext()).inflate(R.layout.item_textview, this);
        mTvName = findViewById(R.id.tv_name);
        mImg = findViewById(R.id.iv_img);

    }
    public void setmTvName(String name){
        if (mTvName != null){
            mTvName.setText(name);
        }
    }
    public void setTxImgResource(int mResource){
       if (mImg !=null){
           mImg.setImageResource(mResource);
       }
    }
}
